<?php

namespace Lowpress\PressBundle\Entity\Repository;

use Doctrine\ORM\EntityRepository;

class ItemRepository extends EntityRepository {

  public function getItemsOrderedByCreated($direction = "DESC")
  {
      return $this->_em
         ->createQueryBuilder()
         ->select('i')
         ->from('Lowpress\PressBundle\Entity\Item', 'i')
         ->orderBy('i.created', $direction)
         ->getQuery()
         ->getResult();
  }
}